<#assign module="member"/>

<@override name="header">
<link rel="stylesheet" href="${ctx}/assets/css/datetimepicker.css">
</@override>
<@override name="body">

<div class="row">
	<div class="col-xs-6" style="width:50%;">
	  	<div class="btn-group">
  			<a class="btn btn-default" href="${ctx}/member/list">所有用户</a>
	  		<a class="btn btn-default" href="${ctx}/member/elist">企业信息</a>
	  		<a class="btn btn-default" href="${ctx}/member/gradelist">用户等级</a>
	  		<@shiro.hasPermission name='blacklist'>
	  			<a class="btn btn-default active" href="${ctx}/member/blacklist">黑名单</a>
	  		</@shiro.hasPermission>
	  		<@shiro.hasPermission name='phonevisit'>
	  			<a class="btn btn-default" href="${ctx}/phonevisit/list">回访记录</a>
	  		</@shiro.hasPermission>
	  		<@shiro.isMainCompany>
			  <@shiro.hasPermission name='memberapply'>
			  	<a class="btn btn-default" href="${ctx}/memberapply/list">VIP申请</a>
			  </@shiro.hasPermission>
		  	</@shiro.isMainCompany>
		  	<@shiro.hasPermission name='receipt'>
		  		<a class="btn btn-default" href="${ctx}/receipt/list">发票申请</a>
		  	</@shiro.hasPermission>
		</div>
	</div>
  	<div class="col-xs-2">
  	</div>
  	<div class="col-xs-4">
		<button class="pull-right btn btn-primary"" onclick="window.location='${ctx}/member/addPersonal';"><b>+</b>&nbsp;添加个人客户</button>
		<button class="pull-right btn btn-primary btn-primary-a"" onclick="window.location='${ctx}/member/addEnterprise';"><b>+</b>&nbsp;添加企业客户</button>
  	</div>
</div>

<div class="row margin-top">
	<div class="col-xs-12">
		<form class="form-inline" role="form">
		    <@shiro.isMainCompany>
				<div class="form-group">
					<select class="form-control" name="companyId">
						<option value="">--全部公司--</option>
						<#if companys??>
							<#list companys as company>
								<option value="${company.id}" <#if companyId?? && companyId==company.id>selected="selected"</#if>>${company.abbreviation?if_exists}</option>
							</#list>
						</#if>
					</select>
			    </div>
		    </@shiro.isMainCompany>
			<div class="form-group">
			    <input type="text" class="form-control" name="param" value="${param?if_exists}" placeholder="模糊搜索">
		  	</div>
		  	<button type="submit" class="btn btn-default"><i class="icon-search"></i>&nbsp;搜索</button>
	    </form>
	</div>
</div>

	    
<div class="row margin-top">
	<div class="col-xs-12">
	<div class="panel panel-primary">
	<div class="table-responsive">
		<table class="table table-hover table-striped">
			<thead>
			<tr style="font-size:14px;">
				<th>联系人</th>
				<th>客户来源</th>
				<th>手机号</th>
				<th>允许签单</th>
				<th>余额</th>
				<th>所属公司</th>
				<th>
					<#if zhuanMethod()>
						代驾 / 专车收费方式
					<#else>
						代驾收费方式
					</#if>
				</th>
				<th>车牌号 / 客户信息</th>
				<th>推荐人</th>
				<th>注册时间</th>
				<th>操作</th>
			</tr>
			</thead>
			<tbody>
				<#if (page.content)?? >
			  	<#list page.content as data>
					<tr>
						<td>${data.name?if_exists}</td>
						<td>${data.channel_name?if_exists}</td>
						<td>
							${data.phone?if_exists}
						</td>
						<td>
							<#if data.allowOverdraw>
								是
							<#else>
								否
							</#if>
						</td>
						<td>
							<#if data.type==0>
								<span style="color:#ff950b;font-weight:700;">${data.drawMoney?if_exists}</span>
							<#elseif data.type==1>
								<span style="color:#ff950b;font-weight:700;">-</span>
							</#if>
						</td>
						<td>${data.companyName?if_exists}</td>
						<td>
							<#if zhuanMethod()>
								<#if data.areaDaijia??>
									${data.areaDaijia.name?if_exists}
								<#else>
									公司统一收费
								</#if>
								/
								<#if data.areaZhuanche??>
									${data.areaZhuanche.name?if_exists}
								<#else>
									公司统一收费
								</#if>
							<#else>
								<#if data.areaDaijia??>
									${data.areaDaijia.name?if_exists}
								<#else>
									公司统一收费
								</#if>
							</#if>
						</td>
						<td>
							${data.plateNumber?if_exists}
						</td>
						<td>
							<#if data.introducer?? && (data.introducer?length>0)>
								${data.introducer}
								<#if data.introduceType==0>
									(客户推荐)
								<#elseif data.introduceType==1>
									(服务人员推荐)
								</#if>
							<#else>
								无
							</#if>
						</td>
						<td>
							${data.created?if_exists}
						</td>
						<td>
						   <div class="btn-group">
							  <a href="${ctx}/member/editPersonal/${data.id}" type="button" class="btn btn-primary btn-xs">编辑</a>
							  <button type="button" class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
							    <span class="caret"></span>
							    <span class="sr-only">Toggle Dropdown</span>
							  </button>
							  <ul class="dropdown-menu" role="menu">
							  		<li><a href="javascript:;" data-value="${data.id}"  class="btn-link unblackthis">解除黑名单</a></li>
									<li><a href="javascript:;" data-value="${data.id}"  class="btn-link deletethis">删除</a></li>
									
									<@shiro.hasPermission name='membermoney'>
										<li>
											<a href="${ctx}/member/money/${data.id}" class="btn-link">账户明细</a>
										</li>
									</@shiro.hasPermission>
									<li>
										<a href="${ctx}/member/couponlist/${data.id}" class="btn-link">查看优惠劵</a>
									</li>
									<li>
										<a href="${ctx}/member/coupongift/${data.id}" class="btn-link">赠送优惠劵</a>
									</li>
									<@shiro.hasPermission name='phonevisit'>
										<li>
											<a href="${ctx}/phonevisit/memberRecord/${data.id}" class="btn-link">回访记录</a>
										</li>
									</@shiro.hasPermission>
									<@shiro.hasPermission name='phonevisit'>
										<li>
											<a href="javascript:;" class="btn-link" onclick="window.open('${ctx}/phonevisit/memberadd/${data.id}', '_blank', 'height=650,width=1024,scrollbars=yes,resizable=yes,alwaysRaised=yes,toolbar=no');">回访</a>
										</li>
									</@shiro.hasPermission>
							  </ul>
							</div>
						</td>
					</tr>
				</#list>
				</#if>
			</tbody>
		</table>
		<#if page.totalElements??>
		<ul class="pagination pull-right pagination-sm">
			<li><a>共 ${page.totalElements} 条数据</a></li>
			<@pg.pager items=page.totalElements?number maxPageItems=20 export="currentPageNumber=pageNumber" url="${ctx}/member/blacklist">
				<@pg.param name="companyId" value="${companyId?if_exists}"/>
				<@pg.param name="param" value="${param?if_exists}"/>
				<@pg.index>
					<@pg.first>
						<li><a href="${pageUrl}">&laquo;</a></li>
					</@pg.first>
					<@pg.prev>
						<li><a href="${pageUrl}">&lsaquo;</a></li>
					</@pg.prev>
					<@pg.pages>
						<#if  currentPageNumber == pageNumber >
							<li class="active"><a href="#">${pageNumber}</a></li>
						<#else>
							<li><a href="${pageUrl}">${pageNumber}</a></li>
						</#if>
					</@pg.pages>
					<@pg.next>
						<li><a href="${pageUrl}">&rsaquo;</a></li>
					</@pg.next>
					<@pg.last>
						<li><a href="${pageUrl}">&raquo;</a></li>
					</@pg.last>
				</@pg.index>
			</@pg.pager>
		</ul>
		</#if>
	</div>
	</div>
	</div>
</div>
</@override>

<@override name="footer">
	<script type="text/javascript">
		window.daijia = {
			ctx:'${ctx}',
			userId:'<@shiro.principal property='id'/>'
		};
	</script>
	<script src="${ctx}/assets/js/pushmessage.js"></script>
	<script src="${ctx}/assets/js/bootstrap-datetimepicker.min.js"></script>
	<script src="${ctx}/assets/js/bootstrap-datetimepicker.zh-CN.js"></script>
	<script type="text/javascript">
		var thisButton;
		function deleteMember() {
		    $.post('${ctx}/member/delete',{'id':thisButton.attr("data-value")},function(data){
		            if(data.success){
		                $.scojs_message('客户删除成功', $.scojs_message.TYPE_OK);
		                window.location.reload(true);
		            } else {
		                $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
		            }
		    },'json');
		}
		
		function unblackMember() {
		    $.post('${ctx}/member/unblack',{'id':thisButton.attr("data-value")},function(data){
		            if(data.success){
		            	$.scojs_message('操作成功', $.scojs_message.TYPE_OK);
		            	window.location.reload(true);
		            } else {
		                $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
		            }
		    },'json');
		}
		
		$(document).ready(function(){
		
			$("#startTime").datetimepicker({ format: 'yyyy-mm-dd', language: 'zh-CN', minView: 'month', pickDate: true, pickTime: false, inputMask: false, autoclose: true });
			$("#endTime").datetimepicker({ format: 'yyyy-mm-dd', language: 'zh-CN', minView: 'month', pickDate: true, pickTime: false, inputMask: false, autoclose: true });
			
		    $(".deletethis").click(function(){
		          thisButton = $(this);
		          var confirm = $.scojs_confirm({
		            content: "您确认要删除客户信息吗？删除后客户的所有相关财务记录余额订单记录将全部清空，你也可以将客户加入黑名单，他/她将无法再下单！",
		            action:deleteMember
		          });
		          confirm.show();
		    });
		    
		    $(".unblackthis").click(function(){
		          thisButton = $(this);
		          var confirm = $.scojs_confirm({
		            content: "您确认要解除该用户的黑名单吗",
		            action:unblackMember
		          });
		          confirm.show();
		    });
		    
		});
	</script>
</@override>
<@extends name="../layout.ftl"/>